#include "stdafx.h"

#include "CommonWindow.h"

CommonWindow::CommonWindow()
{
}


int CommonWindow::RegisterWindow()
{
	WNDCLASSEX wcx={0};
	wcx.cbSize=sizeof(WNDCLASSEX);
	wcx.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
	wcx.hCursor=LoadCursor(NULL,IDC_ARROW);
	wcx.hInstance=GetModuleHandle(NULL);
	wcx.style=CS_DBLCLKS;
	wcx.lpszClassName="HOTELMGR_COMMONWINDOW";
	wcx.lpfnWndProc=CommonWindow::WndProc;
	return RegisterClassEx(&wcx);
}

LRESULT CALLBACK CommonWindow::WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
	return DefWindowProc(hWnd,message,wParam,lParam);
}

RECT* CommonWindow::GetRects()
{
	return m_pRects;
}

int CommonWindow::GetRectsCount()
{
	return m_nRect;
}

class Util
{
public:
	static int DrawRect(HDC,RECT*);
};
int Util::DrawRect(HDC hDC,RECT* rt)
{
	LineTo(hDC,rt->right,rt->top);
	LineTo(hDC,rt->right,rt->bottom);
	LineTo(hDC,rt->left,rt->bottom);
	LineTo(hDC,rt->left,rt->top);
	return 0;
}
int WindowWithBorder::DrawBorder(HWND hWnd)
{
	PAINTSTRUCT ps;
	HDC hDC=BeginPaint(hWnd,&ps);
	EndPaint(hWnd,&ps);

	RECT* pRects;
	pRects=GetRects();
	int n=GetRectsCount();
	for(int i=0; i< n; i++)
	{
		HBRUSH hBr=CreateSolidBrush(RGB(0xcc,0xcc,0xcc));
		Util::DrawRect(hDC,pRects+i);
		DeleteObject(hBr);
	}
	return 0;
}
